/*
 * Copyright 2018 Zhenjie Yan.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.yanzhenjie.andserver.model;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.annotation.JSONField;
import ohos.utils.Parcel;
import ohos.utils.Sequenceable;

/**
 * Created by Zhenjie Yan on 2018/6/9.
 */
public class UserInfo implements Sequenceable {

    @JSONField(name = "userId")
    private String mUserId;

    public String getUserId() {
        return mUserId;
    }

    public void setUserId(String mUserId) {
        this.mUserId = mUserId;
    }

    public String getUserName() {
        return mUserName;
    }

    public void setUserName(String mUserName) {
        this.mUserName = mUserName;
    }

    @JSONField(name = "userName")
    private String mUserName;

    @JSONField(name = "name")
    private String name; //文件的名称
    @JSONField(name = "length")
    private double length;//文件的大小，单位kb

    @JSONField(name = "isDir")
    private boolean isDir;//是否是目录

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public double getLength() {
        return length;
    }

    public void setLength(double length) {
        this.length = length;
    }

    public boolean isDir() {
        return isDir;
    }

    public void setDir(boolean dir) {
        isDir = dir;
    }

    public UserInfo() {
    }
    public UserInfo(String name, double length, boolean isDir) {
        this.name = name;
        this.length = length;
        this.isDir = isDir;
    }
    protected UserInfo(Parcel in) {
        name = in.readString();
        length = in.readDouble();
        isDir=in.readBoolean();
        mUserId = in.readString();
        mUserName = in.readString();
    }

//    @Override
//    public void writeToParcel(Parcel dest, int flags) {
//        dest.writeString(mUserId);
//        dest.writeString(mUserName);
//    }
//
//    @Override
//    public int describeContents() {
//        return 0;
//    }

    public static final Producer<UserInfo> CREATOR = new Producer<UserInfo>() {
        @Override
        public UserInfo createFromParcel(Parcel in) {
            return new UserInfo(in);
        }
    };



    @Override
    public boolean hasFileDescriptor() {
        return false;
    }

    @Override
    public boolean marshalling(Parcel parcel) {
        boolean b = parcel.writeString(name);
        boolean b1 = parcel.writeDouble(length);
        boolean b2=parcel.writeBoolean(isDir);
        if (b && b1 && b2) {
            return true;
        }
        boolean b3 = parcel.writeString(mUserId);
        boolean b4 = parcel.writeString(mUserName);
        if (b3 && b4) {
            return true;
        }
        return false;
    }

    @Override
    public boolean unmarshalling(Parcel parcel) {
        return false;
    }
}